//
//  ViewController.m
//  QianFenHao
//
//  Created by 石虎 on 2017/10/25.
//  Copyright © 2017年 石虎. All rights reserved.
//

#import "ViewController.h"
#import "NSString+Comma.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor orangeColor];
    
    UILabel *attributedLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 200, 300, 80)];
    NSString *text = @"1234512345.6789";
    NSString *testStr = [NSString strmethodComma:text];
    attributedLabel.font = [UIFont systemFontOfSize:30.f];
    attributedLabel.text = testStr;

    
    NSString *floStr;
    NSString *intStr;
    if ([attributedLabel.text containsString:@"."]) {
        
        NSRange range = [attributedLabel.text rangeOfString:@"."];
        intStr = [testStr substringToIndex:range.location];
        floStr = [testStr substringFromIndex:range.location];
    }
    NSLog(@"%@ %@ ",floStr,intStr);
    
    //富文本
    NSRange singleNoRange = NSMakeRange(intStr.length ,floStr.length);
    NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc]initWithString:attributedLabel.text];
    
    [attributedString addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:16] range:singleNoRange];
    
    attributedLabel.attributedText = attributedString;
    
    [self.view addSubview:attributedLabel];

}


@end
